package cn.miw.android.bdmp3.model;

import java.io.Serializable;

@SuppressWarnings("serial")
public class SoSoInfo implements Serializable {
	// {ID:1375842760,
	// song:"依然爱你",
	// singerID:151224278,
	// singer:"王力宏",
	// albumnID:2520803981,
	// albumnName:"火力全开&#32;新歌&#43;精选",
	// qqSongID:974808,
	// qqLocation:9,
	// url:"http://upload9.music.qzone.soso.com/12974808.wma",
	// dur:246},
	private String ID;
	private String song;
	private String singerID;
	private String singer;
	private String albumnID;
	private String albumnName;
	private String qqSongID;
	private String qqLocation;
	private String url;
	private int dur;

	public String getTrueURL() {
		String temp = url;
		if ((temp.indexOf("soso.com") != -1) || (temp.indexOf("qqmusic.qq.com") != -1)) {
			temp = temp.substring(temp.lastIndexOf("/")+1);
			temp = temp.substring(0, temp.length()-4);
			int i = Integer.parseInt(temp) - 12000000 + 30000000;
			String ul = "http://upload" + (Integer.parseInt(qqLocation) + 10) + ".music.qzone.soso.com/" + i + ".mp3";
			String temp_url = ul.replace("upload", "stream").replace(".qzone", "");
			temp = temp_url;
		}
		return temp;
	}

	public String getTimeLong() {
		return dur / 60 + ":" + ("00"+dur % 60).substring(("00"+dur % 60).length()-2);
	}

	public String getID() {
		return ID;
	}

	public void setID(String iD) {
		ID = iD;
	}

	public String getSong() {
		return filterChar(song);
	}

	public void setSong(String song) {
		this.song = song;
	}

	public String getSingerID() {
		return singerID;
	}

	public void setSingerID(String singerID) {
		this.singerID = singerID;
	}

	public String getSinger() {
		return filterChar(singer);
	}

	public void setSinger(String singer) {
		this.singer = singer;
	}

	public String getAlbumnID() {
		return albumnID;
	}

	public void setAlbumnID(String albumnID) {
		this.albumnID = albumnID;
	}

	public String getAlbumnName() {
		return filterChar(albumnName);
	}

	public void setAlbumnName(String albumnName) {
		this.albumnName = albumnName;
	}

	public String getQqSongID() {
		return qqSongID;
	}

	public void setQqSongID(String qqSongID) {
		this.qqSongID = qqSongID;
	}

	public String getQqLocation() {
		return qqLocation;
	}

	public void setQqLocation(String qqLocation) {
		this.qqLocation = qqLocation;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public int getDur() {
		return dur;
	}

	public void setDur(int dur) {
		this.dur = dur;
	}

	@Override
	public String toString() {
		return "Info [ID=" + ID + ", song=" + song + ", singerID=" + singerID + ", singer=" + singer + ", albumnID=" + albumnID
				+ ", albumnName=" + albumnName + ", qqSongID=" + qqSongID + ", qqLocation=" + qqLocation + ", url=" + url + ", dur=" + dur
				+ "]";
	}
	public static String filterChar(String str) {
		return str!=null?str.replaceAll("&#[^&#]*;", " ").trim():"";
	}
}
